package org.alg.graph;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-5-7
 * Time: 下午11:35
 * To change this template use File | Settings | File Templates.
 */
public class DegreesOfSeparation {
    public static void main(String[] args) throws Exception {
        SymbolGraph symbolGraph=new SymbolGraph("D:\\alg-data\\movies.txt","/");
        Graph G=symbolGraph.G();
        String source="Titanic (1997)";
        if(!symbolGraph.constains(source)){
            System.out.println(source+" not in database.");
            return;
        }

        int end=symbolGraph.index(source);
        int start=symbolGraph.index("Animal House (1978)");
        System.out.println(source+" index:"+end+",start:"+start);
        BreadthFirstPaths bfs=new BreadthFirstPaths(G,start);
        if(bfs.hasPathTo(end)){
            for(int v:bfs.pathTo(end)){
                System.out.println("    "+symbolGraph.name(v));

            }
            bfs.printPathToV(end);

            System.out.println(symbolGraph.name(37941));
        }

        System.out.println("print graph...............");
//        System.out.println(G.toString());
    }
}
